//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS SageMakerA2IRuntime service.
///
/// Amazon Augmented AI (Amazon A2I) adds the benefit of human judgment to any machine learning application. When an AI application can't evaluate data with a high degree of confidence, human reviewers can take over. This human review is called a human review workflow. To create and start a human review workflow, you need three resources: a worker task template, a flow definition, and a human loop. For information about these resources and prerequisites for using Amazon A2I, see Get Started with Amazon Augmented AI in the Amazon SageMaker Developer Guide. This API reference includes information about API actions and data types that you can use to interact with Amazon A2I programmatically. Use this guide to:   Start a human loop with the StartHumanLoop operation when using Amazon A2I with a custom task type. To learn more about the difference between custom and built-in task types, see Use Task Types . To learn how to start a human loop using this API, see Create and Start a Human Loop for a Custom Task Type  in the Amazon SageMaker Developer Guide.   Manage your human loops. You can list all human loops that you have created, describe individual human loops, and stop and delete human loops. To learn more, see Monitor and Manage Your Human Loop  in the Amazon SageMaker Developer Guide.   Amazon A2I integrates APIs from various AWS services to create and start human review workflows for those services. To learn how Amazon A2I uses these APIs, see Use APIs in Amazon A2I in the Amazon SageMaker Developer Guide.
public struct SageMakerA2IRuntime: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the SageMakerA2IRuntime client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "SageMakerA2IRuntime",
            serviceIdentifier: "a2i-runtime.sagemaker",
            signingName: "sagemaker",
            serviceProtocol: .restjson,
            apiVersion: "2019-11-07",
            endpoint: endpoint,
            errorType: SageMakerA2IRuntimeErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Deletes the specified human loop for a flow definition. If the human loop was deleted, this operation will return a ResourceNotFoundException.
    @Sendable
    @inlinable
    public func deleteHumanLoop(_ input: DeleteHumanLoopRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DeleteHumanLoopResponse {
        try await self.client.execute(
            operation: "DeleteHumanLoop", 
            path: "/human-loops/{HumanLoopName}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes the specified human loop for a flow definition. If the human loop was deleted, this operation will return a ResourceNotFoundException.
    ///
    /// Parameters:
    ///   - humanLoopName: The name of the human loop that you want to delete.
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteHumanLoop(
        humanLoopName: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeleteHumanLoopResponse {
        let input = DeleteHumanLoopRequest(
            humanLoopName: humanLoopName
        )
        return try await self.deleteHumanLoop(input, logger: logger)
    }

    /// Returns information about the specified human loop. If the human loop was deleted, this operation will return a ResourceNotFoundException error.
    @Sendable
    @inlinable
    public func describeHumanLoop(_ input: DescribeHumanLoopRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DescribeHumanLoopResponse {
        try await self.client.execute(
            operation: "DescribeHumanLoop", 
            path: "/human-loops/{HumanLoopName}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns information about the specified human loop. If the human loop was deleted, this operation will return a ResourceNotFoundException error.
    ///
    /// Parameters:
    ///   - humanLoopName: The name of the human loop that you want information about.
    ///   - logger: Logger use during operation
    @inlinable
    public func describeHumanLoop(
        humanLoopName: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DescribeHumanLoopResponse {
        let input = DescribeHumanLoopRequest(
            humanLoopName: humanLoopName
        )
        return try await self.describeHumanLoop(input, logger: logger)
    }

    /// Returns information about human loops, given the specified parameters. If a human loop was deleted, it will not be included.
    @Sendable
    @inlinable
    public func listHumanLoops(_ input: ListHumanLoopsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListHumanLoopsResponse {
        try await self.client.execute(
            operation: "ListHumanLoops", 
            path: "/human-loops", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns information about human loops, given the specified parameters. If a human loop was deleted, it will not be included.
    ///
    /// Parameters:
    ///   - creationTimeAfter: (Optional) The timestamp of the date when you want the human loops to begin in ISO 8601 format. For example, 2020-02-24.
    ///   - creationTimeBefore: (Optional) The timestamp of the date before which you want the human loops to begin in ISO 8601 format. For example, 2020-02-24.
    ///   - flowDefinitionArn: The Amazon Resource Name (ARN) of a flow definition.
    ///   - maxResults: The total number of items to return. If the total number of available items is more than the value specified in MaxResults, then a NextToken is returned in the output. You can use this token to display the next page of results.
    ///   - nextToken: A token to display the next page of results.
    ///   - sortOrder: Optional. The order for displaying results. Valid values: Ascending and Descending.
    ///   - logger: Logger use during operation
    @inlinable
    public func listHumanLoops(
        creationTimeAfter: Date? = nil,
        creationTimeBefore: Date? = nil,
        flowDefinitionArn: String? = nil,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        sortOrder: SortOrder? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListHumanLoopsResponse {
        let input = ListHumanLoopsRequest(
            creationTimeAfter: creationTimeAfter, 
            creationTimeBefore: creationTimeBefore, 
            flowDefinitionArn: flowDefinitionArn, 
            maxResults: maxResults, 
            nextToken: nextToken, 
            sortOrder: sortOrder
        )
        return try await self.listHumanLoops(input, logger: logger)
    }

    /// Starts a human loop, provided that at least one activation condition is met.
    @Sendable
    @inlinable
    public func startHumanLoop(_ input: StartHumanLoopRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> StartHumanLoopResponse {
        try await self.client.execute(
            operation: "StartHumanLoop", 
            path: "/human-loops", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Starts a human loop, provided that at least one activation condition is met.
    ///
    /// Parameters:
    ///   - dataAttributes: Attributes of the specified data. Use DataAttributes to specify if your data is free of personally identifiable information and/or free of adult content.
    ///   - flowDefinitionArn: The Amazon Resource Name (ARN) of the flow definition associated with this human loop.
    ///   - humanLoopInput: An object that contains information about the human loop.
    ///   - humanLoopName: The name of the human loop.
    ///   - logger: Logger use during operation
    @inlinable
    public func startHumanLoop(
        dataAttributes: HumanLoopDataAttributes? = nil,
        flowDefinitionArn: String? = nil,
        humanLoopInput: HumanLoopInput? = nil,
        humanLoopName: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> StartHumanLoopResponse {
        let input = StartHumanLoopRequest(
            dataAttributes: dataAttributes, 
            flowDefinitionArn: flowDefinitionArn, 
            humanLoopInput: humanLoopInput, 
            humanLoopName: humanLoopName
        )
        return try await self.startHumanLoop(input, logger: logger)
    }

    /// Stops the specified human loop.
    @Sendable
    @inlinable
    public func stopHumanLoop(_ input: StopHumanLoopRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> StopHumanLoopResponse {
        try await self.client.execute(
            operation: "StopHumanLoop", 
            path: "/human-loops/stop", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Stops the specified human loop.
    ///
    /// Parameters:
    ///   - humanLoopName: The name of the human loop that you want to stop.
    ///   - logger: Logger use during operation
    @inlinable
    public func stopHumanLoop(
        humanLoopName: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> StopHumanLoopResponse {
        let input = StopHumanLoopRequest(
            humanLoopName: humanLoopName
        )
        return try await self.stopHumanLoop(input, logger: logger)
    }
}

extension SageMakerA2IRuntime {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: SageMakerA2IRuntime, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension SageMakerA2IRuntime {
    /// Return PaginatorSequence for operation ``listHumanLoops(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listHumanLoopsPaginator(
        _ input: ListHumanLoopsRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListHumanLoopsRequest, ListHumanLoopsResponse> {
        return .init(
            input: input,
            command: self.listHumanLoops,
            inputKey: \ListHumanLoopsRequest.nextToken,
            outputKey: \ListHumanLoopsResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listHumanLoops(_:logger:)``.
    ///
    /// - Parameters:
    ///   - creationTimeAfter: (Optional) The timestamp of the date when you want the human loops to begin in ISO 8601 format. For example, 2020-02-24.
    ///   - creationTimeBefore: (Optional) The timestamp of the date before which you want the human loops to begin in ISO 8601 format. For example, 2020-02-24.
    ///   - flowDefinitionArn: The Amazon Resource Name (ARN) of a flow definition.
    ///   - maxResults: The total number of items to return. If the total number of available items is more than the value specified in MaxResults, then a NextToken is returned in the output. You can use this token to display the next page of results.
    ///   - sortOrder: Optional. The order for displaying results. Valid values: Ascending and Descending.
    ///   - logger: Logger used for logging
    @inlinable
    public func listHumanLoopsPaginator(
        creationTimeAfter: Date? = nil,
        creationTimeBefore: Date? = nil,
        flowDefinitionArn: String? = nil,
        maxResults: Int? = nil,
        sortOrder: SortOrder? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListHumanLoopsRequest, ListHumanLoopsResponse> {
        let input = ListHumanLoopsRequest(
            creationTimeAfter: creationTimeAfter, 
            creationTimeBefore: creationTimeBefore, 
            flowDefinitionArn: flowDefinitionArn, 
            maxResults: maxResults, 
            sortOrder: sortOrder
        )
        return self.listHumanLoopsPaginator(input, logger: logger)
    }
}

extension SageMakerA2IRuntime.ListHumanLoopsRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> SageMakerA2IRuntime.ListHumanLoopsRequest {
        return .init(
            creationTimeAfter: self.creationTimeAfter,
            creationTimeBefore: self.creationTimeBefore,
            flowDefinitionArn: self.flowDefinitionArn,
            maxResults: self.maxResults,
            nextToken: token,
            sortOrder: self.sortOrder
        )
    }
}
